import { IFeidaoAiMobile } from '@dfeidao/atom-mobile/interfaces';
import get from '@dfeidao/atom-mobile/local/get';
import set from '@dfeidao/atom-mobile/local/set';
// 上拉加载
import nodejs from '@dfeidao/atom-mobile/msg/nodejs';
import render from '@dfeidao/atom-mobile/render/render';
export default async function a005(fd: IFeidaoAiMobile) {
	const user = await get(fd, 'user_who') as {
		params: {
			teacher_name: string;
			productid: string;
			teacher_no: string;
		}
	};
	const page_on = await get(fd, 'page') as number;
	const data = await get(fd, 'data') as [];
	const auditor_status = await get(fd, 'auditor_status') as [];
	const page_ons = page_on + 1;
	const d = await nodejs<[]>('app-parental-leave/s002', {
		filter: {
			teacher_no: user.params.teacher_no,// todo ps.params.teacher_no
			auditor_status,
			productid: user.params.productid
		},
		page_size: 10,
		page_on: page_ons
	});
	if (d.length >= 4 || JSON.stringify(d) === '[]') {

		const a = d.concat(data).map((item: {}, i) => {
			return { ...item, index: i };
		});
		await set(fd, 'page', page_ons);
		await set(fd, 'data', a);
		setTimeout(() => {
			render(fd, {
				d: a, c: page_on, len: d.length
			});
		}, 500);
	}
}
